//
//  ChooseKindCell.m
//  AnnCar_user
//
//  Created by LiBenCan on 17/10/27.
//  Copyright © 2017年 LiBenCan. All rights reserved.
//

#import "ChooseKindCell.h"
#import "chooseBtnView.h"
@implementation ChooseKindCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = 0;
    }
    return self;
}
//创建UI
- (void)loadCellArr:(NSArray *)listArr
{
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    
    //种类
    _kindLab = [TomamaUI createLabel:CGRectMake(15*screenW_6, 0, SCREENW, 39*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:15*screenW_6] textColor:TextBlack text:@"电子券类型"];
    [self.contentView addSubview:_kindLab];
    
    //线
    [self.contentView addSubview:[ToolViewVC addCellLineLab:CGRectMake(15*screenW_6, 39*screenW_6, SCREENW-30*screenW_6, 1*screenW_6)]];
    
    //选择
    for (int i = 0; i<listArr.count; i++) {
        _x = _x+(50*screenW_6+_btnWidth)*i;
        _btnWidth = [TomamaUI getStringHeightWith:listArr[i] andWeith:SCREENW/2 andFont:[UIFont systemFontOfSize:14*screenW_6]];
        chooseBtnView *btnView = [[chooseBtnView alloc]initWithFrame:CGRectMake(_x,40*screenW_6,50*screenW_6+_btnWidth,45*screenW_6) Title:listArr[i] NomolImageV:@"circle" SelectImageV:@"circle_select" IsSelect:NO];
        [self.contentView addSubview:btnView];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector( btnTap:)];
        [btnView addGestureRecognizer:tap];
    }
  
    
}
//选择按钮
-(void)btnTap:(UITapGestureRecognizer *)tap
{
    chooseBtnView *btnView = (id)tap.view;
    btnView.isChoose = !btnView.isChoose;//反选按钮
    btnView.leftImagV.image = [UIImage imageNamed:btnView.isChoose?@"circle_select":@"circle"];
 
}
@end
